import {
  GET_LIST_DATA, 
  LEFT_CLICK, 
  ADD_SELECT_ITEM, 
  MIN_SELECT_ITEM,
  SHOW_CHOOSE_CONTENT,
  CLEAR_CAR
} from './actionType.js'

import axios from 'axios'

export const getListData = () => async(dispatch) => {
  let res = await axios({
    url: 'json/food.json',
    method: 'get'
  })
  dispatch({
    type: GET_LIST_DATA,
    obj: res.data
  })
}

export const itemClick = (obj) => {
  return {
    type: LEFT_CLICK,
    obj
  }
}

export const addSelectItem = (obj) => {
  return {
    type: ADD_SELECT_ITEM,
    obj
  }
}

export const minSelectItem = (obj) => {
  return {
    type: MIN_SELECT_ITEM,
    obj
  }
}

export const showChoose = (obj) => {
  return {
    type: SHOW_CHOOSE_CONTENT,
    obj
  }
}

export const clearCar = (obj) => {
  return {
    type: CLEAR_CAR,
    obj
  }
}